import { useEffect, useState } from 'react';
import { fileDownload } from '@/services/mail';

// 邮件下载请求第三方服务
const useFileDown = query => {
    const [loading, setLoading] = useState(false);
    const [resData, setResData] = useState(null);

    const fetchData = async () => {
        setLoading(true);
        const res = await fileDownload(query);
        setResData(res);

        setLoading(false);
    };
    useEffect(() => {
        if (query) {
            fetchData();
        }
    }, [query]);
    return [loading, resData];
};

export default useFileDown;
